package com.ztc.ZtcDriver.service;

import com.aqgj.util.Pager;
import com.ztc.ZtcDriver.bean.ZtcDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ztc.ZtcDriver.dao.ZtcDriverDao;

import java.util.List;

@Service("ZtcDriver")
public class ZtcDriverManager {
    @Autowired
    ZtcDriverDao ztcDriverDao;

    /**
     * 根据公司id获取司机信息.
     *
     * @param transportId 车方公司id
     * @return 司机信息
     */
    public List<ZtcDriver> getZtcDriverByTransportId(String transportId) {
        return ztcDriverDao.findBy("transportId", transportId,"status","5");
    }

    public void removeById(String did) {
        ztcDriverDao.removeById(did);
    }

    /**
     * 更新司机状态.
     *
     * @param did    司机id
     * @param status  状态
     * @return 是否更新
     */
    public boolean updataZcDriverStatus(String did, String status) {
        boolean isTrue = false;
        int res = ztcDriverDao.updateZcDriverStatus(did, status);
        if (res > 0) {
            isTrue = true;
        }
        return isTrue;
    }

    public String save(ZtcDriver ztcDriver) {
        ztcDriverDao.save(ztcDriver);
        return ztcDriver.getId();
    }

    public ZtcDriver findUniqueBy(String propertyName, Object value) {
        return ztcDriverDao.findUniqueBy(propertyName, value);
    }

    public List<ZtcDriver> findBy(String propertyName1, Object value1, String propertyName2, Object value2) {
        return ztcDriverDao.findBy(propertyName1, value1, propertyName2, value2);
    }

    public List<ZtcDriver> findBy(String propertyName, Object value) {
        return ztcDriverDao.findBy(propertyName, value);
    }

    public ZtcDriver get(String zid) {
        return ztcDriverDao.get(zid);
    }

    public String update(ZtcDriver ztcDriver) {
        return ztcDriverDao.update(ztcDriver);
    }

    public Pager<ZtcDriver> getDriverListByTransportId(String transportId, Integer pageSize, Integer pageNumber, Integer transportType, String search,String status) {
        return ztcDriverDao.getDriverListByTransportId(transportId, pageSize, pageNumber, transportType,search,status);
    }

    public List<ZtcDriver> getDriverListByTransportId(String id, Integer type) {
        return ztcDriverDao.getDriverListByTransportId(id,type);
    }

    //获取所有驾驶证证件到期且未被冻结的司机
    public List<ZtcDriver> getExpireDriverList() {
        return ztcDriverDao.getExpireDriverList();
    }
}
